$(function(){
    var $slide = $('#slide'),
        $point = $('#point'),
        screenwidth = $slide.width(),
        len = $slide.find('li').length;
    var pages = len/4;
    $slide.find('ul').width(screenwidth*pages);
    $slide.find('li').width(screenwidth*pages/len);
    $slide.css('visibility','visible');
    var pointhtml = '<a class="active" href="javascript:void(0)"></a>';
    for(var i=1; i<Math.ceil(pages);i++){
        pointhtml+='<a href="javascript:void(0)"></a>';
    }
    $point.html(pointhtml);
    var curpage = 0;

    var setid = '';
    function setId(){
        if(pages > 1) {
            setid = setInterval(function () {
                curpage++;
                if (curpage > pages) {
                    curpage = 0;
                }
                move(curpage);
            }, 3000);
        }
    }
    setId();
    $point.find('a').click(function(){
        clearInterval(setid);
        curpage = $(this).index();
        move(curpage);
    });
    $('.dream-bottom').on('mouseenter',function(){
        clearInterval(setid);
    }).on('mouseleave',function(){
        setId();
    });

    function move(curpage){
        $slide.find('ul').css('margin-left',-screenwidth*curpage);
        $point.find('a').removeClass('active');
        $point.find('a').eq(curpage).addClass('active');
    }
});